package com.example.demo.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.sql.SQLException;

@Configuration
@Data
public class DataSourceConfig {
    @ConfigurationProperties("spring.datasource")
    @Bean(initMethod = "init")
    public DataSource getDataSource() throws JsonProcessingException, SQLException {
        DruidDataSource dataSource = new DruidDataSource();
        return dataSource;
    }
}
